<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/vue.js"></script>
	</head>
	<body>
		<div id="box">
			<input type="text" v-model="inData">
			<button @click="handleClick()">添加待办事项</button>
			<div v-if="dataList.length === 0">待办事项空空如也</div>
			<ul v-else>
				数据列表：
				<li v-for="(item,index) in dataList">
					第{{index+1}}个:{{item}}
					<button @click="handleDel(index)">删除</button>
				</li>
			</ul>
		</div>
		<script>
			var vm = new Vue({
				el: "#box",
				data:{
					dataList:[],
					inData:""
				},
				methods:{
					handleClick(){
						this.dataList.push(this.inData)
						this.inData=""
					},
					handleDel(index){
						this.dataList.splice(index,1)
					}
				}
			})
		</script>
	</body>
</html>